/*
*去空格
*/
function trim(value){
		return value.replace(/(^\s*)|(\s*$)/g,"");
}
/*
*IN NULL OR EMPTY
*/
function isNullOrEmpty(value){
	alert("3");
	if(value != undefined){
		trim(value);
	}
	//value=value.trim();
	var result = false;
	if (value == null || 
		value == undefined || 
		value == "null" || 
		value == ""){
		result = true;
	}
	return result;
}
// 字符串是否为数字
function strIsNum(str){
	var num;
	
	num = new Number(str);
	return !isNaN(num);
}



function numAddShopCar(value){
	
	var ids="";
	//alert(value);
	
	var buyNumber=document.getElementById("buyNumber").value;
	//alert(value);
	if(isNullOrEmpty(buyNumber)){
		buyNumber=1;
		window.location.href=jsCtx+"/shopping/viewShoppingCart.do?m=addProductForward&id="+value+"&number="+buyNumber;
	}else if(strIsNum(buyNumber)){
		if(buyNumber<=0){
			alert("请输入大于0的数字");
				return;
		}else{
			window.location.href=jsCtx+"/shopping/viewShoppingCart.do?m=addProductForward&id="+value+"&number="+buyNumber;
		}
	}else{
		alert("请输入大于0的数字");
		return false;
	}
}

function ToAddShopCar(){
	var recommendNum=0;
	var checkboxes=document.getElementsByName("recommendCheckbox");
	for(var i = 0; i < checkboxes.length; i++){	
		if(checkboxes[i].checked==true){
				recommendNum++;			
		}
	}
document.getElementById("recommendNum").innerHTML=recommendNum;
}
function AddShopCar(){
	var recommendIds="";
	var checkboxes=document.getElementsByName("recommendCheckbox");
	
	
	for(var i = 0; i < checkboxes.length; i++){	
		if(checkboxes[i].checked==true){
				recommendIds+=checkboxes[i].value+',';
		}
	}
	if(recommendIds=="" || recommendIds==null){issuanceGrade
		alert('请选择商品！');
		return;
	}
	window.location.href=jsCtx+"/shopping/addToShoppingCart.do?m=addProductForward&productId="+recommendIds;
}
function fenqi(){
	window.open(jsCtx+"/jsp/shoppingcart/fenqi.jsp");
}
//商品评分 --我来评分  
function grade(uid,productId){
	if(isNullOrEmpty(uid)){
		alert("请先登陆！");
		return;
	}else{
		window.open(jsCtx+'/jsp/shop/grade.jsp?productId='+productId+'&uid='+uid,'','height=344,width=400,menubar=no, scrollbars=no, resizable=no,location=no, status=no')
	}
}
